package pnt.message;

import java.net.InetSocketAddress;

import pnt.message.objects.User;

public class Utils {

	public static String formatSocketAddresses(InetSocketAddress[] ia){
		if (ia == null) return "NULL";
        String s = "";
        int plen = ia.length;
        for (int n = 0; n < plen; n++){
            InetSocketAddress i = ia[n];
            s += formatSocketAddress(i) + 
                 ((n+1 == plen)? "" : ",");
        }
        
        return s;
	}
	
	public static String formatSocketAddress(InetSocketAddress i){
		if (i == null) return "NULL";
        String s = "(" + 
             i.getAddress().getHostAddress() + 
             "," + 
             i.getPort() + ")";
        
        return s;
	}
	
	public static String formatUsers(User[] u){
		String s = "";
		int len = u.length;
		for(int i = 0; i < len; i++)
			s += u[i].toString() + (i == len - 1 ? "":", ");
		return s;
	}
	
}
